import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
from uncertainties import ufloat, unumpy
from scipy.signal import find_peaks
def oscillator(t, A, B, omega_plus, omega_minus, phi, d, C):
return A*np.cos(omega_plus*(t-d)+phi) + B*np.cos(omega_minus*(t-d)+phi) + C
filenames = []
for i in range(1, 51):
filename = "/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/ALL{:04d}".format(i) + ".CSV"
filenames.append(filename)
for i, file1 in enumerate(filenames):
data = np.genfromtxt(file1, skip_header=18, delimiter=',')
data[:, 0] = data[:, 0] - data[:, 0][0]
data[:, 1] = data[:, 1] / np.max(data[:, 1])
data[:, 2] = data[:, 2] - data[:, 2][0]
data[:, 3] = data[:, 3] / np.max(data[:, 3])
np.savetxt('DLL{:04d}'.format(i+1) + '.CSV', data, delimiter=',')
# filename = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/ALL0050.CSV'
# data = np.genfromtxt(filename, skip_header=18, delimiter=',')
# # t1 = data[:, 0] # first wave
# data[:, 0] = data[:, 0] - data[:, 0][0]
# # y1 = data[:, 1] # first wave
# data[:, 1] = data[:, 1] / np.max(data[:, 1])
# # t2 = data[:, 2] # second wave
# data[:, 2] = data[:, 2] - data[:, 2][0]
# # y2 = data[:, 3] # second wave
# data[:, 3] = data[:, 3] / np.max(data[:, 3])
# Create an empty list to store fit parameters for each file
fit_params1 = []
fit_params2 = []
fit_params1_u = []
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0001.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.617704, 0.243294, 70.7494, 84.239, 319.04, -0.0768066, 0.0858925)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 6.02832851e-01 2.49472640e-01 7.12286778e+01 8.33260685e+01 3.16989030e+02 -1.03993326e-01 8.62407749e-02] [0.6028328505761817+/-0.0008766872438814897, 0.24947263953669144+/-0.0008756776010593886, 71.22867776252346+/-0.0025066616016685903, 83.32606845641814+/-0.006094205937276608, 316.989029532129+/-0.04746256212381065, -0.10399332560862665+/-0.0006526268653386184, 0.08624077494866184+/-0.0006155370800141696] 5.283+/-0.013 0.5637+/-0.0010
[[ 7.68580524e-07 2.36824478e-08 1.51761995e-08 -4.56947517e-07 -2.48776918e-06 -3.48929193e-08 -9.42783208e-09] [ 2.36824478e-08 7.66811261e-07 2.24914950e-07 2.02813486e-08 -1.15823362e-06 -1.32197830e-08 -7.19123808e-09] [ 1.51761995e-08 2.24914950e-07 6.28335239e-06 6.42283112e-07 -3.85895795e-05 -4.44334319e-07 2.37039720e-08] [-4.56947517e-07 2.02813486e-08 6.42283112e-07 3.71393460e-05 2.32215731e-04 3.28217440e-06 1.70175054e-08] [-2.48776918e-06 -1.15823362e-06 -3.85895795e-05 2.32215731e-04 2.25269480e-03 3.09135290e-05 -1.95585048e-07] [-3.48929193e-08 -1.32197830e-08 -4.44334319e-07 3.28217440e-06 3.09135290e-05 4.25921825e-07 -2.32283158e-09] [-9.42783208e-09 -7.19123808e-09 2.37039720e-08 1.70175054e-08 -1.95585048e-07 -2.32283158e-09 3.78885897e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0001.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1]-0.1 # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
y1_square = y1**2
# Normalise the data
y1_square = y1_square / max(y1_square)
peaks1, _ = find_peaks(y1_square, height=0.1, distance=60)
y2_square = y2**2
# Normalise the data
y2_square = y2_square / max(y2_square)
peaks2, _ = find_peaks(y2_square, height=0.1, distance=60)
def sine_squared(x, A, omega, phi, C):
return A * np.sin(omega * x + phi)**2 + C
t1_peaks = t1[peaks1]
y1_peaks = y1_square[peaks1]
t2_peaks = t2[peaks2]
y2_peaks = y2_square[peaks2]
# Write squared amplitude data to file as (x,y) pairs
np.savetxt('test_please.txt', np.transpose([t1_peaks, y1_peaks]), delimiter=',', fmt='%1.3f')
popt1, _ = curve_fit(sine_squared, t1_peaks, y1_peaks, p0=[-0.636255, 5.99238, 0.711885,0.868247])
popt2, _ = curve_fit(sine_squared, t2_peaks, y2_peaks, p0=[-0.636255, 5.99238, 0.711885,0.868247])
# Plot the fitted curves
# first intialise point for fitted function
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = sine_squared(curve_t1, *popt1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = sine_squared(curve_t2, *popt2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1_peaks, y1_peaks, 'o', label='Recorded data', markerfacecolor='none', markeredgecolor='red')
ax1.plot(curve_t1, curve_y1, 'blue', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Squared amplitude of first oscillator')
ax1.legend()
ax2.plot(t2_peaks, y2_peaks, 'o', label='Recorded data', markerfacecolor='none', markeredgecolor='red')
ax2.plot(curve_t2, curve_y2, 'blue', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Squared amplitude of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}_squared.png",dpi=600)
plt.show()
import matplotlib.pyplot as plt
from uncertainties import ufloat
# Define your ufloat objects
x = ufloat(5.0, 0.1)
y = ufloat(10.0, 0.2)
# Extract the nominal values and uncertainties
x_nom, x_err = x.nominal_value, x.std_dev
y_nom, y_err = y.nominal_value, y.std_dev
# Plot the data points with error bars
plt.errorbar(x_nom, y_nom, xerr=x_err, yerr=y_err, fmt='o', ecolor='red', capsize=3, label='data')
# Customize the plot
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.grid()
# Show the plot
plt.show()
from uncertainties import ufloat
# Define the least count of your instrument
least_count = 0.01
# Define the nominal value of your quantity
nominal_value = 5.23
# Calculate the standard deviation (absolute uncertainty) based on the desired number of significant figures
absolute_uncertainty = least_count / (2 ** (3 - 1)) # for 3 significant figures
# print(absolute_uncertainty)
# Create a ufloat object with the specified precision
x = ufloat(nominal_value, std_dev=absolute_uncertainty)
# Print the result
print(x/np.pi)
1.6648+/-0.0008
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0002.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 4.11167970e-01 -2.63314179e-01 6.66994064e+01 7.78773056e+01 -2.44914194e+00 -3.90757336e-02 3.90185157e-01] [0.4111679696622801+/-0.0008913826575017156, -0.263314178926821+/-0.0008931765327616398, 66.69940638892083+/-0.003773416755365028, 77.87730562366055+/-0.005852991233092359, -2.4491419368493346+/-0.05390754808507162, -0.039075733605439436+/-0.0007668325869014624, 0.39018515687624433+/-0.0006275112263188515] 3.188+/-0.013 0.7153+/-0.0012
[[ 7.94563042e-07 4.01566071e-08 -1.39166126e-09 1.66187285e-07 2.41677408e-06 3.60390964e-08 -4.26065194e-09] [ 4.01566071e-08 7.97764319e-07 4.92603174e-08 2.83030604e-08 -1.11105214e-06 -1.38246144e-08 5.52238529e-09] [-1.39166126e-09 4.92603174e-08 1.42386740e-05 -3.21317545e-06 -1.19231635e-04 -1.56686596e-06 -4.96873453e-08] [ 1.66187285e-07 2.83030604e-08 -3.21317545e-06 3.42575064e-05 2.31183974e-04 3.42413842e-06 9.87882703e-08] [ 2.41677408e-06 -1.11105214e-06 -1.19231635e-04 2.31183974e-04 2.90602374e-03 4.12458937e-05 1.05459636e-06] [ 3.60390964e-08 -1.38246144e-08 -1.56686596e-06 3.42413842e-06 4.12458937e-05 5.88032216e-07 1.48585236e-08] [-4.26065194e-09 5.52238529e-09 -4.96873453e-08 9.87882703e-08 1.05459636e-06 1.48585236e-08 3.93770339e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0003.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.546048, -0.250184, 70.3442, 81.7136, -0.616721, -0.0141077,0.315169)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 5.26084480e-01 -2.52044285e-01 7.00337857e+01 8.18012128e+01 -6.18223339e-02 -7.27984217e-03 3.29848833e-01] [0.5260844796292719+/-0.0010776653736181592, -0.25204428516995186+/-0.001073967763208402, 70.03378568553332+/-0.0035289104126274952, 81.8012128119324+/-0.0074386548187201544, -0.06182233387622268+/-0.05885253716637174, -0.007279842168476501+/-0.0008126232231560339, 0.3298488332277108+/-0.0007557076811623209] 4.595+/-0.015 0.6103+/-0.0012
[[ 1.16136266e-06 5.61203168e-08 -1.55305458e-08 6.57469528e-07 5.20375625e-06 7.41850387e-08 -1.28600334e-09] [ 5.61203168e-08 1.15340676e-06 3.24821492e-07 3.50589344e-09 -2.53517176e-06 -3.04568909e-08 -2.22683486e-09] [-1.55305458e-08 3.24821492e-07 1.24532087e-05 -2.80483505e-06 -9.65014239e-05 -1.19961235e-06 -1.87128126e-08] [ 6.57469528e-07 3.50589344e-09 -2.80483505e-06 5.53335855e-05 3.39586520e-04 4.82564239e-06 1.29884832e-07] [ 5.20375625e-06 -2.53517176e-06 -9.65014239e-05 3.39586520e-04 3.46362113e-03 4.77329061e-05 1.07640383e-06] [ 7.41850387e-08 -3.04568909e-08 -1.19961235e-06 4.82564239e-06 4.77329061e-05 6.60356503e-07 1.47962370e-08] [-1.28600334e-09 -2.22683486e-09 -1.87128126e-08 1.29884832e-07 1.07640383e-06 1.47962370e-08 5.71094099e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0004.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.561579, -0.236223, 68.788, 79.9736, 16.9465, 0.255952,0.298113)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-0.5446235 -0.22993728 68.56355841 80.1232401 16.78497677 0.25370543 0.31092937] [-0.544623498275428+/-0.0009489707153492546, -0.2299372827959889+/-0.0009504150565227379, 68.5635584110043+/-0.0030786316726434514, 80.12324009691369+/-0.007248901018249597, 16.784976768797012+/-0.04596797522474291, 0.2537054311381035+/-0.0006512668963721277, 0.3109293729468358+/-0.0006694921680027013] 5.227+/-0.014 0.5483+/-0.0012
[[ 9.00545419e-07 -4.10304764e-08 1.52640573e-09 -4.76009451e-07 -3.35457132e-06 -4.88925268e-08 2.99374577e-09] [-4.10304764e-08 9.03288780e-07 1.67212087e-07 3.60112138e-08 -1.24577360e-06 -1.50672343e-08 5.06416449e-09] [ 1.52640573e-09 1.67212087e-07 9.47797298e-06 -3.38577305e-06 -5.88164740e-05 -7.55208107e-07 2.33353251e-08] [-4.76009451e-07 3.60112138e-08 -3.38577305e-06 5.25465660e-05 2.43867033e-04 3.53210660e-06 -5.26483180e-09] [-3.35457132e-06 -1.24577360e-06 -5.88164740e-05 2.43867033e-04 2.11305475e-03 2.98895686e-05 -5.03411352e-07] [-4.88925268e-08 -1.50672343e-08 -7.55208107e-07 3.53210660e-06 2.98895686e-05 4.24148570e-07 -6.89532216e-09] [ 2.99374577e-09 5.06416449e-09 2.33353251e-08 -5.26483180e-09 -5.03411352e-07 -6.89532216e-09 4.48219763e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0005.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.558248, 0.311921, 70.0122, 84.3834, 11.1523, 0.15291,0.109455)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-0.53708288 0.3129484 70.76200778 83.33731605 11.2034884 0.15365554 0.11055988] [-0.5370828814353253+/-0.0008773877969893139, 0.31294839909477384+/-0.0008786713540435786, 70.762007784974+/-0.0028560871937169277, 83.3373160482577+/-0.004885172054286114, 11.20348840343644+/-0.03248053900134373, 0.15365554162741343+/-0.00043961091448726364, 0.1105598786939134+/-0.0006202337454111222] 0.390+/-0.013 0.9681+/-0.0011
[[ 7.69809346e-07 4.27172482e-10 2.03489171e-08 1.86199418e-07 7.51228273e-07 1.09818474e-08 4.27715154e-09] [ 4.27172482e-10 7.72063348e-07 1.32465264e-07 3.99506849e-08 -4.64062609e-07 -4.97283454e-09 -9.17478845e-09] [ 2.03489171e-08 1.32465264e-07 8.15723406e-06 -2.17724614e-07 -4.10444937e-05 -4.83192851e-07 1.03714064e-10] [ 1.86199418e-07 3.99506849e-08 -2.17724614e-07 2.38649060e-05 1.08414410e-04 1.54303366e-06 1.58541705e-08] [ 7.51228273e-07 -4.64062609e-07 -4.10444937e-05 1.08414410e-04 1.05498541e-03 1.42323125e-05 -5.91688885e-08] [ 1.09818474e-08 -4.97283454e-09 -4.83192851e-07 1.54303366e-06 1.42323125e-05 1.93257756e-07 -5.62030034e-10] [ 4.27715154e-09 -9.17478845e-09 1.03714064e-10 1.58541705e-08 -5.91688885e-08 -5.62030034e-10 3.84689899e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0006.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.651862, 0.318967, 70.6589, 82.7447, 20.5068, 0.284488,-0.0686323)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 5.91923230e-01 2.96753992e-01 7.07557270e+01 8.24834486e+01 2.07034517e+01 2.87100598e-01 -6.28849629e-02] [0.5919232296607547+/-0.0016494239984993753, 0.29675399199546065+/-0.0016499199332853014, 70.7557269576022+/-0.004849539163609891, 82.48344862713203+/-0.009643565949000473, 20.703451681299423+/-0.06049992538709235, 0.287100597702503+/-0.0008271773497704378, -0.06288496292411881+/-0.001162285074085865] 2.506+/-0.021 0.7850+/-0.0018
[[ 2.72059953e-06 -9.57199538e-08 -3.90163891e-08 9.74942554e-07 7.30758092e-06 1.03228581e-07 1.83400659e-08] [-9.57199538e-08 2.72223579e-06 -3.47753660e-07 -7.04887534e-08 2.64179210e-06 3.02811821e-08 1.49271365e-08] [-3.90163891e-08 -3.47753660e-07 2.35180301e-05 -3.07897673e-06 -1.14390952e-04 -1.38280951e-06 -6.62766842e-09] [ 9.74942554e-07 -7.04887534e-08 -3.07897673e-06 9.29983642e-05 3.96019836e-04 5.60171769e-06 1.20619885e-07] [ 7.30758092e-06 2.64179210e-06 -1.14390952e-04 3.96019836e-04 3.66024097e-03 4.99341799e-05 1.37570893e-06] [ 1.03228581e-07 3.02811821e-08 -1.38280951e-06 5.60171769e-06 4.99341799e-05 6.84222368e-07 1.85683917e-08] [ 1.83400659e-08 1.49271365e-08 -6.62766842e-09 1.20619885e-07 1.37570893e-06 1.85683917e-08 1.35090659e-06]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0007.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.728487, -0.273514, 71.9745, 83.3814, 16.0856, 0.221014,-0.0388383)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-6.82891448e-01 -2.87199461e-01 7.15301025e+01 8.31029279e+01 1.61260195e+01 2.21591665e-01 -5.04401866e-02] [-0.6828914483755059+/-0.0010680726762442659, -0.28719946111750133+/-0.0010660181903577011, 71.53010246482768+/-0.002722932312580742, 83.10292789092968+/-0.006508482762560832, 16.12601947321692+/-0.044284867898286555, 0.2215916646792159+/-0.0006015445701125661, -0.050440186639432824+/-0.0007492375881964177] 4.069+/-0.014 0.6486+/-0.0012
[[ 1.14077924e-06 -7.59449214e-08 2.34476189e-08 -5.75297719e-07 -3.72234514e-06 -5.17316824e-08 1.03717037e-08] [-7.59449214e-08 1.13639478e-06 2.48660111e-07 -4.21223997e-08 -1.81030471e-06 -2.20331892e-08 -7.52776927e-09] [ 2.34476189e-08 2.48660111e-07 7.41436038e-06 -3.02278116e-06 -5.27618809e-05 -6.57396963e-07 4.39205278e-08] [-5.75297719e-07 -4.21223997e-08 -3.02278116e-06 4.23603479e-05 2.14546627e-04 2.97313382e-06 -8.77316031e-09] [-3.72234514e-06 -1.81030471e-06 -5.27618809e-05 2.14546627e-04 1.96114952e-03 2.66024492e-05 -5.60949065e-07] [-5.17316824e-08 -2.20331892e-08 -6.57396963e-07 2.97313382e-06 2.66024492e-05 3.61855870e-07 -7.25903793e-09] [ 1.03717037e-08 -7.52776927e-09 4.39205278e-08 -8.77316031e-09 -5.60949065e-07 -7.25903793e-09 5.61356964e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0008.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.629115, -0.393968, 72.4765,84.3245, 28.1047, 0.373013,-0.0546951)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 5.95796649e-01 -3.86062870e-01 7.23123748e+01 8.39407589e+01 2.81680096e+01 3.74737994e-01 -6.12818301e-02] [0.5957966494982392+/-0.0009515036972745039, -0.38606287022783464+/-0.0009507294585084519, 72.31237475614438+/-0.002787050030347758, 83.94075887290329+/-0.004319399545611312, 28.16800959467982+/-0.030686133720473675, 0.37473799385856854+/-0.00040290833978102314, -0.0612818300818298+/-0.000670534609460526] 2.606+/-0.013 0.7755+/-0.0011
[[ 9.05359286e-07 3.08399570e-08 2.33780791e-08 1.89780870e-07 -1.70969519e-07 -2.24695503e-09 -3.98252056e-10] [ 3.08399570e-08 9.03886503e-07 1.64656433e-07 1.65990102e-09 -8.52053134e-08 -9.87341741e-10 -4.75268334e-09] [ 2.33780791e-08 1.64656433e-07 7.76764787e-06 -1.35376132e-06 -4.38605562e-05 -5.39409771e-07 -2.53275520e-08] [ 1.89780870e-07 1.65990102e-09 -1.35376132e-06 1.86572124e-05 8.33275091e-05 1.13272591e-06 -2.29370014e-08] [-1.70969519e-07 -8.52053134e-08 -4.38605562e-05 8.33275091e-05 9.41638803e-04 1.23416370e-05 -8.43538600e-08] [-2.24695503e-09 -9.87341741e-10 -5.39409771e-07 1.13272591e-06 1.23416370e-05 1.62335130e-07 -1.37528836e-09] [-3.98252056e-10 -4.75268334e-09 -2.53275520e-08 -2.29370014e-08 -8.43538600e-08 -1.37528836e-09 4.49616662e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0009.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.579014, 0.429924, 74.5056, 84.4381, 14.4796, 0.211825,-0.00407155)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 6.01083766e-01 4.23533615e-01 7.38029475e+01 8.55123493e+01 1.41985578e+01 2.08322528e-01 -1.62207755e-02] [0.6010837659179852+/-0.0011972503817469676, 0.4235336150270919+/-0.001195591376888729, 73.80294749897546+/-0.00350268144554125, 85.51234929538106+/-0.005004488319362337, 14.19855775341296+/-0.041870361561836565, 0.2083225279826899+/-0.0005365028751534483, -0.01622077553041057+/-0.0008411268785074807] 2.122+/-0.015 0.8192+/-0.0013
[[ 1.43340848e-06 -8.51748368e-08 -7.39815230e-09 5.92076027e-07 3.25394712e-06 4.40355662e-08 -1.66059904e-08] [-8.51748368e-08 1.42943874e-06 -4.68222157e-07 7.20680584e-08 3.12159425e-06 3.70169391e-08 1.18578053e-08] [-7.39815230e-09 -4.68222157e-07 1.22687773e-05 -3.05587097e-06 -8.56026996e-05 -1.02779778e-06 -1.57105625e-08] [ 5.92076027e-07 7.20680584e-08 -3.05587097e-06 2.50449033e-05 1.41499707e-04 1.88610627e-06 8.58496255e-08] [ 3.25394712e-06 3.12159425e-06 -8.56026996e-05 1.41499707e-04 1.75312718e-03 2.24195093e-05 6.33100310e-07] [ 4.40355662e-08 3.70169391e-08 -1.02779778e-06 1.88610627e-06 2.24195093e-05 2.87835335e-07 8.25936234e-09] [-1.66059904e-08 1.18578053e-08 -1.57105625e-08 8.58496255e-08 6.33100310e-07 8.25936234e-09 7.07494426e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0010.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.558154, -0.357801, 71.0281, 84.5704, -74.3868, -1.00709,0.0552442)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-5.57663731e-01 -3.55152341e-01 7.15358505e+01 8.38158859e+01 -8.34896081e+01 -1.12612929e+00 5.79585072e-02] [-0.5576637312583168+/-0.0009027594973100481, -0.35515234123177813+/-0.0009029352908607184, 71.5358505400259+/-0.0028028660087194134, 83.81588589545335+/-0.004400088392842974, -83.48960812334154+/-0.06854165777638536, -1.1261292935324352+/-0.000911881782480976, 0.05795850715293078+/-0.0006353943002453395] 4.546+/-0.013 0.6252+/-0.0010
[[ 8.14974710e-07 1.62010669e-08 -6.83879953e-09 3.06862994e-07 3.49981333e-06 4.90300908e-08 -7.38147180e-09] [ 1.62010669e-08 8.15292139e-07 -2.02513209e-07 5.07585353e-09 2.62367347e-06 3.10580177e-08 -6.62995071e-09] [-6.83879953e-09 -2.02513209e-07 7.85605786e-06 -1.79928404e-08 -1.09490957e-04 -1.29706906e-06 -3.71241254e-08] [ 3.06862994e-07 5.07585353e-09 -1.79928404e-08 1.93607779e-05 2.34621462e-04 3.29065029e-06 -4.46965507e-08] [ 3.49981333e-06 2.62367347e-06 -1.09490957e-04 2.34621462e-04 4.69795885e-03 6.23118779e-05 8.26858817e-08] [ 4.90300908e-08 3.10580177e-08 -1.29706906e-06 3.29065029e-06 6.23118779e-05 8.31528385e-07 -7.11883721e-11] [-7.38147180e-09 -6.62995071e-09 -3.71241254e-08 -4.46965507e-08 8.26858817e-08 -7.11883721e-11 4.03725917e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0011.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.517836, -0.503835, 71.5207, 83.2292, 13.7552, 0.188763,-0.085009)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-0.5213786 -0.47116594 71.2983173 83.72605012 13.86526552 0.190213 -0.101477 ] [-0.5213785959008195+/-0.0012127298809841078, -0.47116593651471683+/-0.00121589097685414, 71.29831730132305+/-0.004033063567194529, 83.72605012116256+/-0.004436598548677151, 13.865265515074698+/-0.0380954141001441, 0.19021299975689465+/-0.0004937479540521297, -0.1014769977994353+/-0.0008520312176030796] 3.586+/-0.018 0.7023+/-0.0015
[[ 1.47071376e-06 -2.00249273e-08 -2.19149257e-08 -5.84725706e-07 -2.82936796e-06 -3.93269272e-08 1.50718018e-08] [-2.00249273e-08 1.47839087e-06 5.70521889e-07 -7.57340921e-09 -3.10033894e-06 -3.74355032e-08 -1.40549188e-08] [-2.19149257e-08 5.70521889e-07 1.62656017e-05 3.14792991e-07 -9.15953142e-05 -1.10077812e-06 4.75457278e-08] [-5.84725706e-07 -7.57340921e-09 3.14792991e-07 1.96834067e-05 9.51570379e-05 1.32662076e-06 -5.88853074e-08] [-2.82936796e-06 -3.10033894e-06 -9.15953142e-05 9.51570379e-05 1.45126058e-03 1.87564486e-05 -7.05144950e-07] [-3.93269272e-08 -3.74355032e-08 -1.10077812e-06 1.32662076e-06 1.87564486e-05 2.43787042e-07 -9.03309602e-09] [ 1.50718018e-08 -1.40549188e-08 4.75457278e-08 -5.88853074e-08 -7.05144950e-07 -9.03309602e-09 7.25957196e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0012.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.478788, -0.499061, 70.968, 82.0318, 13.7428, 0.184593,-0.0217016)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-4.77709875e-01 -4.64459438e-01 7.07755124e+01 8.23963627e+01 1.38821574e+01 1.86418553e-01 -3.46640523e-02] [-0.47770987477636845+/-0.0009603109079447191, -0.4644594383247497+/-0.0009602235110514017, 70.77551242828808+/-0.003531776987751232, 82.39636272458277+/-0.0036328240709218897, 13.882157421792233+/-0.03520700375753264, 0.1864185527359133+/-0.0004597495266053007, -0.03466405226474782+/-0.000674286407891005] 2.138+/-0.015 0.8133+/-0.0013
[[ 9.22197040e-07 -6.34497406e-08 3.95099697e-08 -3.42772791e-07 -1.84671902e-06 -2.56356608e-08 8.29459132e-09] [-6.34497406e-08 9.22029191e-07 3.32348864e-07 -3.88204228e-08 -2.20245659e-06 -2.72568219e-08 -5.74544893e-09] [ 3.95099697e-08 3.32348864e-07 1.24734487e-05 -2.32431387e-06 -8.25221228e-05 -1.02395942e-06 -2.99348791e-09] [-3.42772791e-07 -3.88204228e-08 -2.32431387e-06 1.31974107e-05 7.83346736e-05 1.08091035e-06 3.55886567e-08] [-1.84671902e-06 -2.20245659e-06 -8.25221228e-05 7.83346736e-05 1.23953311e-03 1.61512012e-05 -2.46264534e-08] [-2.56356608e-08 -2.72568219e-08 -1.02395942e-06 1.08091035e-06 1.61512012e-05 2.11369627e-07 -9.55995440e-11] [ 8.29459132e-09 -5.74544893e-09 -2.99348791e-09 3.55886567e-08 -2.46264534e-08 -9.55995440e-11 4.54662160e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0013.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.324642, -0.374597, 70.1241, 82.0966, -86.2839,-1.04032,0.407284)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.31173238 -0.36600126 69.88597902 81.96054196 -84.94499009 -1.02595148 0.41959928] [0.31173238309548684+/-0.0010749405973102034, -0.3660012640431906+/-0.0010771609186232397, 69.88597902179343+/-0.006089210506736596, 81.96054196145798+/-0.005144911537772495, -84.94499008933794+/-0.10879282890808739, -1.02595147697862+/-0.001411052830822567, 0.4195992789521959+/-0.0007583531346031879] 1.861+/-0.015 0.8417+/-0.0013
[[ 1.15549729e-06 2.97128423e-08 -2.74568390e-08 5.98862173e-07 7.60719502e-06 1.08457622e-07 -9.41508070e-09] [ 2.97128423e-08 1.16027564e-06 6.51741107e-07 1.67480038e-09 -9.54480936e-06 -1.16235241e-07 -5.60539913e-09] [-2.74568390e-08 6.51741107e-07 3.70784846e-05 -2.46483086e-06 -5.29491463e-04 -6.50369356e-06 -1.27863037e-07] [ 5.98862173e-07 1.67480038e-09 -2.46483086e-06 2.64701147e-05 3.34639803e-04 4.73743329e-06 9.52300924e-08] [ 7.60719502e-06 -9.54480936e-06 -5.29491463e-04 3.34639803e-04 1.18358796e-02 1.53083352e-04 2.79518587e-06] [ 1.08457622e-07 -1.16235241e-07 -6.50369356e-06 4.73743329e-06 1.53083352e-04 1.99107009e-06 3.63228798e-08] [-9.41508070e-09 -5.60539913e-09 -1.27863037e-07 9.52300924e-08 2.79518587e-06 3.63228798e-08 5.75099477e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0014.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.328968, 0.3165,69.4405, 81.5231, -80.8409, -0.959339,0.439319)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.31338536 0.30377543 69.48592917 81.14122088 -84.1125869 -1.00512071 0.44860152] [0.313385364611594+/-0.0008274093022522113, 0.3037754290889471+/-0.0008278725996287193, 69.4859291680323+/-0.00455204456448342, 81.14122088048853+/-0.004691136385479011, -84.11258689723114+/-0.09221490906526243, -1.0051207100979789+/-0.0012238656702720915, 0.44860152308609696+/-0.0005825101756364395] 2.188+/-0.013 0.8088+/-0.0011
[[ 6.84606153e-07 -9.45919770e-09 5.63746424e-08 8.44112150e-08 -6.69483640e-07 -8.01823483e-09 -5.02849566e-10] [-9.45919770e-09 6.85373041e-07 -6.09451687e-08 -4.84720917e-08 -7.42865580e-07 -1.02939203e-08 -4.19335306e-09] [ 5.63746424e-08 -6.09451687e-08 2.07211097e-05 -6.99591853e-07 -3.06380005e-04 -3.81001383e-06 -2.08981149e-08] [ 8.44112150e-08 -4.84720917e-08 -6.99591853e-07 2.20067606e-05 2.82535080e-04 4.02629545e-06 6.98373216e-08] [-6.69483640e-07 -7.42865580e-07 -3.06380005e-04 2.82535080e-04 8.50358945e-03 1.12576586e-04 1.09244268e-06] [-8.01823483e-09 -1.02939203e-08 -3.81001383e-06 4.02629545e-06 1.12576586e-04 1.49784718e-06 1.52010248e-08] [-5.02849566e-10 -4.19335306e-09 -2.08981149e-08 6.98373216e-08 1.09244268e-06 1.52010248e-08 3.39318105e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0015.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.386026, 0.366413, 78.7167, 74.3603, -54.5867, -0.487906,0.186711)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-5.50623323e-01 7.29384956e-02 8.03629400e+01 7.31090656e+01 -4.07263659e+01 -3.03157657e-01 1.78920375e-01] [-0.5506233232584926+/-0.0043801278427655745, 0.07293849558917295+/-0.004400568700130244, 80.36294004481032+/-0.01501928756167266, 73.10906563906815+/-0.11215147199334634, -40.72636593068417+/-1.8322017693233572, -0.3031576568683362+/-0.022919407756283955, 0.17892037452777848+/-0.003063837785723894] -4.66+/-0.12 1.628+/-0.014
[[ 1.91855199e-05 2.06796743e-06 2.43210149e-06 -5.27530508e-05 7.94188373e-04 9.92030670e-06 1.02395997e-07] [ 2.06796743e-06 1.93650049e-05 -7.92870597e-06 1.81489706e-05 -3.50347927e-04 -4.49040778e-06 -8.45805040e-08] [ 2.43210149e-06 -7.92870597e-06 2.25578999e-04 -6.75117061e-04 1.25986337e-02 1.60432344e-04 3.91865971e-07] [-5.27530508e-05 1.81489706e-05 -6.75117061e-04 1.25779527e-02 -1.90032712e-01 -2.37552588e-03 -4.37150130e-06] [ 7.94188373e-04 -3.50347927e-04 1.25986337e-02 -1.90032712e-01 3.35696332e+00 4.19907830e-02 8.75921583e-05] [ 9.92030670e-06 -4.49040778e-06 1.60432344e-04 -2.37552588e-03 4.19907830e-02 5.25299252e-04 1.09200602e-06] [ 1.02395997e-07 -8.45805040e-08 3.91865971e-07 -4.37150130e-06 8.75921583e-05 1.09200602e-06 9.38710198e-06]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0016.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.347121, 0.674219,67.7857, 78.6945, 2.27378,0.411542,0.140963)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-0.39130189 0.64199942 68.07484069 79.44673706 1.42836851 0.39807972 0.15482097] [-0.39130188563167306+/-0.001465326402229925, 0.6419994175679531+/-0.001470307410399929, 68.07484069414943+/-0.006664696418833538, 79.44673706271536+/-0.004010003135736331, 1.4283685073244958+/-0.046164805060546224, 0.3980797222893441+/-0.0006058075670139239, 0.15482096877457058+/-0.0010337203038920369] -0.252+/-0.015 1.0227+/-0.0014
[[ 2.14718147e-06 1.50255028e-07 1.42658952e-07 -4.08950250e-07 -1.27069479e-06 -1.72522299e-08 -1.59399304e-09] [ 1.50255028e-07 2.16180388e-06 -4.68536520e-07 1.13098982e-08 4.96418406e-07 6.62536518e-09 1.20533483e-08] [ 1.42658952e-07 -4.68536520e-07 4.44181784e-05 -5.07818098e-06 -2.08909232e-04 -2.67392413e-06 -1.46392143e-08] [-4.08950250e-07 1.13098982e-08 -5.07818098e-06 1.60801251e-05 8.26761249e-05 1.16272992e-06 3.84366217e-08] [-1.27069479e-06 4.96418406e-07 -2.08909232e-04 8.26761249e-05 2.13118923e-03 2.79216893e-05 -4.99463408e-07] [-1.72522299e-08 6.62536518e-09 -2.67392413e-06 1.16272992e-06 2.79216893e-05 3.67002808e-07 -6.38851992e-09] [-1.59399304e-09 1.20533483e-08 -1.46392143e-08 3.84366217e-08 -4.99463408e-07 -6.38851992e-09 1.06857767e-06]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0017.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.477289,-0.38479, 67.7511, 79.2813, 21.5836, 0.658985,0.180285)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-0.46129773 -0.37616966 67.50221578 79.33738355 20.61015244 0.64649305 0.18277777] [-0.4612977268771531+/-0.0007905217816424976, -0.37616965775135186+/-0.0007930354743868708, 67.50221577504745+/-0.002987886115561624, 79.33738354550768+/-0.003629087815496523, 20.610152435096627+/-0.020879096470166614, 0.6464930548486857+/-0.0002876116847066264, 0.18277777473684553+/-0.0005572298568789261] 3.710+/-0.011 0.6779+/-0.0009
[[ 6.24924687e-07 -1.98524716e-08 -2.38509648e-08 -1.77492420e-07 5.76405762e-08 8.77818803e-10 8.42200693e-09] [-1.98524716e-08 6.28905264e-07 1.32318272e-07 1.29656575e-08 1.45548531e-07 1.77917475e-09 -3.91440054e-10] [-2.38509648e-08 1.32318272e-07 8.92746344e-06 -6.82719186e-07 -2.70311897e-05 -3.52412763e-07 -4.57928093e-09] [-1.77492420e-07 1.29656575e-08 -6.82719186e-07 1.31702784e-05 3.30217395e-05 4.75547717e-07 2.41306320e-09] [ 5.76405762e-08 1.45548531e-07 -2.70311897e-05 3.30217395e-05 4.35936669e-04 5.99029313e-06 1.73718013e-07] [ 8.77818803e-10 1.77917475e-09 -3.52412763e-07 4.75547717e-07 5.99029313e-06 8.27204812e-08 2.40731350e-09] [ 8.42200693e-09 -3.91440054e-10 -4.57928093e-09 2.41306320e-09 1.73718013e-07 2.40731350e-09 3.10505113e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0018.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.488047, 0.523338,67.2362, 78.2814, 24.5811, 0.685933,0.144698)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.50848301 0.5069891 67.21593153 78.55727847 23.04123056 0.66379967 0.15526642] [0.5084830104265694+/-0.0013703799094467487, 0.5069891032248653+/-0.001366842581474375, 67.21593152652316+/-0.0046786903747566295, 78.55727847031386+/-0.004723418474535515, 23.04123055795138+/-0.03025307922795487, 0.6637996664431187+/-0.0004144368018480511, 0.15526642498740448+/-0.0009621607208850758] 2.271+/-0.015 0.7954+/-0.0013
[[ 1.87794110e-06 -1.29443939e-07 -7.82272453e-08 3.17608689e-07 -3.60787614e-07 -5.83108195e-09 -5.60918467e-10] [-1.29443939e-07 1.86825864e-06 -3.34416425e-07 2.85303316e-08 -2.60407759e-07 -3.02355888e-09 1.80406423e-09] [-7.82272453e-08 -3.34416425e-07 2.18901436e-05 -3.68174747e-06 -6.20935100e-05 -8.13281423e-07 -1.91612593e-08] [ 3.17608689e-07 2.85303316e-08 -3.68174747e-06 2.23106821e-05 5.81465943e-05 8.38535126e-07 9.36312379e-08] [-3.60787614e-07 -2.60407759e-07 -6.20935100e-05 5.81465943e-05 9.15248803e-04 1.25085395e-05 -1.22574693e-07] [-5.83108195e-09 -3.02355888e-09 -8.13281423e-07 8.38535126e-07 1.25085395e-05 1.71757863e-07 -1.19097726e-09] [-5.60918467e-10 1.80406423e-09 -1.91612593e-08 9.36312379e-08 -1.22574693e-07 -1.19097726e-09 9.25753253e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0019.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.37875133 -0.61762316 66.17233722 77.72902702 21.91282826 0.30134846 0.18180951] [0.37875132701162645+/-0.0012991163655134235, -0.617623160037611+/-0.0012988867333221354, 66.17233721754062+/-0.0059478135657552505, 77.72902701718182+/-0.0036532393005249265, 21.91282825796102+/-0.04184757735318713, 0.3013484564498189+/-0.0005606414339470528, 0.18180951121663336+/-0.0009159683261164964] 0.302+/-0.015 0.9728+/-0.0013
[[ 1.68770333e-06 -2.02661883e-08 8.49548385e-08 -4.56011015e-08 -1.79674496e-06 -2.60450136e-08 2.53380359e-09] [-2.02661883e-08 1.68710675e-06 -2.28499917e-07 2.51176053e-08 3.29321212e-06 4.24378974e-08 -1.14914307e-08] [ 8.49548385e-08 -2.28499917e-07 3.53764862e-05 1.13164730e-06 -1.69080208e-04 -2.17968771e-06 1.01991686e-07] [-4.56011015e-08 2.51176053e-08 1.13164730e-06 1.33461574e-05 5.54351785e-05 8.32567261e-07 -4.71892913e-08] [-1.79674496e-06 3.29321212e-06 -1.69080208e-04 5.54351785e-05 1.75121973e-03 2.34105743e-05 -5.58684713e-07] [-2.60450136e-08 4.24378974e-08 -2.17968771e-06 8.32567261e-07 2.34105743e-05 3.14318817e-07 -7.42163966e-09] [ 2.53380359e-09 -1.14914307e-08 1.01991686e-07 -4.71892913e-08 -5.58684713e-07 -7.42163966e-09 8.38997974e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0020.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (-0.303663, -0.539404, 82.7955,70.4074, -7.07838, 0.0886124,0.212848)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
fit_params1_u.append([DELTA_u, GEOMETRIC_PHASE_u/np.pi])
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[-2.91750980e-01 -5.21730565e-01 8.26634137e+01 7.06081713e+01 -7.61266977e+00 8.15893773e-02 2.19780689e-01] [-0.2917509799376274+/-0.0008210086498802296, -0.5217305652573686+/-0.000820608743810809, 82.66341366265827+/-0.004908539638342449, 70.60817128733754+/-0.002748163261870378, -7.612669768885203+/-0.0390098032617205, 0.08158937734435592+/-0.0005277000603470319, 0.21978068868964304+/-0.0005799841980669023] 5.441+/-0.013 0.5396+/-0.0011
[[ 6.74055203e-07 -6.51443606e-10 2.18512122e-08 -4.13056939e-08 7.05551596e-07 8.68350394e-09 -4.81271091e-09] [-6.51443606e-10 6.73398710e-07 7.83389351e-10 -1.82442896e-08 6.65051574e-07 9.20126286e-09 -7.64166916e-09] [ 2.18512122e-08 7.83389351e-10 2.40937614e-05 2.32938612e-07 1.34556088e-04 1.89414505e-06 2.68922086e-08] [-4.13056939e-08 -1.82442896e-08 2.32938612e-07 7.55240131e-06 -5.26247119e-05 -6.46511801e-07 5.97364503e-09] [ 7.05551596e-07 6.65051574e-07 1.34556088e-04 -5.26247119e-05 1.52176475e-03 2.05436953e-05 -7.48546764e-08] [ 8.68350394e-09 9.20126286e-09 1.89414505e-06 -6.46511801e-07 2.05436953e-05 2.78467354e-07 -8.33476280e-10] [-4.81271091e-09 -7.64166916e-09 2.68922086e-08 5.97364503e-09 -7.48546764e-08 -8.33476280e-10 3.36381670e-07]]
print(fit_params1_u)
[[5.2831908608464815+/-0.01267016390940623, 0.5637400979881095+/-0.0010325383338358946], [3.187684308313301+/-0.013185240056478564, 0.7153459223375095+/-0.0011656237230191907], [4.595355768537046+/-0.014833057600325812, 0.6102819314153171+/-0.0012399527407925375], [5.226924904474802+/-0.013602210118298255, 0.548284168956419+/-0.0011516851266831528], [0.3897152726455064+/-0.013467169104883383, 0.9681241133896051+/-0.0011015498689590886], [2.5059324820130744+/-0.021478717951822338, 0.7849636619241145+/-0.0018470931148938175], [4.068661941854386+/-0.014457452376371655, 0.648633774672168+/-0.0012381201175586938], [2.6057465915411+/-0.012542342130810657, 0.7754515739233369+/-0.0010784743021435151], [2.121971359044168+/-0.01485690034484048, 0.8191592049066053+/-0.0012643496566472976], [4.546130844138357+/-0.012658220431993553, 0.6251526950979296+/-0.0010410808890022327], [3.5864319920108128+/-0.017515645875469204, 0.7022906617688278+/-0.001480604250979609], [2.1380813419469025+/-0.014725856213509343, 0.8132655185151229+/-0.0012985357810653662], [1.8614370207651885+/-0.015065618684535686, 0.8416720774636364+/-0.0012531012720696064], [2.187856746423425+/-0.012912676973101144, 0.8088441629287284+/-0.001111020030237521], [-4.656726945050587+/-0.12281974082618781, 1.6277478280330673+/-0.014066820577823505], [-0.25221724492618613+/-0.015219800200089425, 1.0227359021057174+/-0.0013732188939223858], [3.709682526990622+/-0.010854872676031264, 0.6779029675833492+/-0.0009369491096808034], [2.2711110494631783+/-0.014969194939064442, 0.7953993019410621+/-0.0013454612066427058], [0.30243747880048777+/-0.014608488009115893, 0.9727797385269734+/-0.0013136767000468464], [5.440930776545025+/-0.012670835242660989, 0.5395658455349749+/-0.001062977710156991]]
# Plot of omega_plus and omega_minus with detuning with error bars
# Detuning is first element in fit_params1_u
# omega_plus and omega_minus are third and fourth elements in fit_params1
omega_plus_u = np.array([fit_params1[i][2].nominal_value for i in range(len(fit_params1))])
omega_minus_u = np.array([fit_params1[i][3].nominal_value for i in range(len(fit_params1))])
omega_plus_u_err = np.array([fit_params1[i][2].std_dev for i in range(len(fit_params1))])
omega_minus_u_err = np.array([fit_params1[i][3].std_dev for i in range(len(fit_params1))])
x_nom = np.array([fit_params1_u[i][0].nominal_value for i in range(len(fit_params1_u))])
x_err = np.array([fit_params1_u[i][0].std_dev for i in range(len(fit_params1_u))])
# Define fit function
def parabolic1(x, a, b):
return a * x**2 + b
def parabolic2(x, a, b):
return -a * x**2 + b
# Fit parabola to data
popt1, pcov1 = curve_fit(parabolic2, x_nom, omega_plus_u, sigma=omega_plus_u_err)
popt2, pcov2 = curve_fit(parabolic1, x_nom, omega_minus_u, sigma=omega_minus_u_err)
# Plot data
plt.errorbar(x_nom, omega_plus_u, yerr=omega_plus_u_err, fmt='o', label='omega_plus')
plt.errorbar(x_nom, omega_minus_u, yerr=omega_minus_u_err, fmt='o', label='omega_minus')
# Plot fit
x = np.linspace(-6, 6, 1000)
plt.plot(x, parabolic1(x, *popt1), label='omega_plus fit')
plt.plot(x, parabolic2(x, *popt2), label='omega_minus fit')
plt.xlabel('Detuning (rad/s)')
plt.ylabel('Frequency (rad/s)')
plt.legend()
plt.savefig(f"{file1[-6:-4]}_freq_det.png",dpi=600)
plt.show()
import matplotlib.pyplot as plt
from uncertainties import ufloat
# Geometric phase fit function
def phi_G(DELTA, OMEGA):
return (1 - (DELTA / (np.sqrt(OMEGA**2 + DELTA**2))))
# Get x and y data points
x_nom = np.array([fit_params1_u[i][0].nominal_value for i in range(len(fit_params1_u))])
x_err = np.array([fit_params1_u[i][0].std_dev for i in range(len(fit_params1_u))])
y_nom = np.array([fit_params1_u[i][1].nominal_value for i in range(len(fit_params1_u))])
y_err = np.array([fit_params1_u[i][1].std_dev for i in range(len(fit_params1_u))])
print(x_nom)
# Plot data points with error bars
# Fit function
popt, pcov = curve_fit(phi_G, x_nom, y_nom, sigma=y_err, absolute_sigma=True)
# Plot fitted function with figure size
x_fit = np.linspace(-15, 15, 1000)
y_fit = phi_G(x_fit, *popt)
plt.plot(x_fit, y_fit, label='fit')
plt.errorbar(x_nom, y_nom, xerr=x_err, yerr=y_err, fmt='o', label='data')
plt.title('Geometric phase vs detuning')
plt.xlabel('Detuning (rad/s)')
plt.ylabel('Geometric phase (rad)')
plt.legend()
plt.grid()
plt.savefig('Geometric_phase.png', dpi=600)
plt.show()
# Make another plot with x and y limits
plt.plot(x_fit, y_fit, label='fit')
plt.errorbar(x_nom, y_nom, xerr=x_err, yerr=y_err, fmt='o', label='data')
plt.title('Geometric phase vs detuning')
plt.xlabel('Detuning (rad/s)')
plt.ylabel('Geometric phase (rad)')
plt.legend()
plt.grid()
plt.xlim(2, 3)
plt.ylim(0.77, 0.83)
plt.savefig('Zoomed_in_geometric_phase.png', dpi=600)
plt.show()
# plt.xlabel('x')
# plt.ylabel('y')
# # plt.legend()
# plt.grid()
# plt.show()
[ 5.28319086 3.18768431 4.59535577 5.2269249 0.38971527 2.50593248 4.06866194 2.60574659 2.12197136 4.54613084 3.58643199 2.13808134 1.86143702 2.18785675 -4.65672695 -0.25221724 3.70968253 2.27111105 0.30243748 5.44093078]
priwq()
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[148], line 1 ----> 1 priwq() NameError: name 'priwq' is not defined
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0021.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 3.97809996e-01 -1.33845262e-01 6.98822238e+01 7.74240187e+01 -3.09546990e+01 -3.98114312e-01 -4.52110941e-03] [0.3978099957103442+/-0.00869865500184032, -0.13384526197518135+/-0.00867657084619289, 69.88222377105308+/-0.038259021045759393, 77.4240186791027+/-0.11440071400711042, -30.954699017230414+/-1.7727413188240733, -0.3981143117160962+/-0.02500444505943994, -0.004521109407801245+/-0.006102271276098041] 4.96+/-0.12 0.334+/-0.013
[[ 7.56665988e-05 4.03864759e-06 -7.05726059e-08 -2.71881301e-05 -9.34395993e-04 -1.33934323e-05 4.52118270e-07] [ 4.03864759e-06 7.52828816e-05 -2.75377070e-06 7.31735451e-07 2.83764965e-04 3.69992410e-06 2.30565865e-07] [-7.05726059e-08 -2.75377070e-06 1.46375269e-03 -7.95040596e-04 -3.01876890e-02 -4.02814727e-04 4.22821383e-06] [-2.71881301e-05 7.31735452e-07 -7.95040596e-04 1.30875234e-02 1.79032887e-01 2.54760795e-03 7.52978838e-07] [-9.34395993e-04 2.83764965e-04 -3.01876890e-02 1.79032887e-01 3.14261178e+00 4.43072888e-02 -7.40866537e-06] [-1.33934323e-05 3.69992410e-06 -4.02814727e-04 2.54760795e-03 4.43072888e-02 6.25222273e-04 -5.67413523e-09] [ 4.52118270e-07 2.30565865e-07 4.22821383e-06 7.52978838e-07 -7.40866537e-06 -5.67413523e-09 3.72377147e-05]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0022.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.44357458 -0.54796012 69.43268199 81.15732869 -16.69137198 -0.21162736 0.09960627] [0.4435745830185995+/-0.0009872078626389446, -0.5479601210390312+/-0.000987905046379929, 69.43268198672432+/-0.003842035352498661, 81.15732869055165+/-0.003106185717939965, -16.69137197900905+/-0.04506274669171473, -0.2116273565426713+/-0.0005882436570598744, 0.09960627268668201+/-0.0006954040445517175] 1.530+/-0.014 0.8653+/-0.0013
[[ 9.74579364e-07 -4.53909880e-09 6.46206290e-08 -2.74394206e-08 -1.41121146e-06 -1.91966227e-08 3.74783907e-10] [-4.53909880e-09 9.75956381e-07 -1.88068180e-08 4.06958246e-08 1.46800525e-06 1.87226047e-08 5.94391034e-09] [ 6.46206290e-08 -1.88068180e-08 1.47612356e-05 1.19548602e-07 -1.27566681e-04 -1.58018455e-06 1.13383973e-08] [-2.74394206e-08 4.06958246e-08 1.19548602e-07 9.64838971e-06 7.38625972e-05 1.05410415e-06 5.54175547e-08] [-1.41121146e-06 1.46800525e-06 -1.27566681e-04 7.38625972e-05 2.03065114e-03 2.64447645e-05 2.73722832e-07] [-1.91966227e-08 1.87226047e-08 -1.58018455e-06 1.05410415e-06 2.64447645e-05 3.46030600e-07 4.19975206e-09] [ 3.74783907e-10 5.94391034e-09 1.13383973e-08 5.54175547e-08 2.73722832e-07 4.19975206e-09 4.83586785e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0023.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 2.56879321e-01 -4.77770884e-01 6.88517163e+01 8.09290474e+01 -7.14673353e+00 -6.21044361e-02 2.30038778e-01] [0.2568793209822806+/-0.0008144086572772019, -0.47777088406296414+/-0.0008137715539790311, 68.8517163480441+/-0.005454072182255095, 80.92904738685272+/-0.002927956628798931, -7.146733525921261+/-0.0500178667473273, -0.06210443611877052+/-0.0006399709793007929, 0.23003877823325106+/-0.0005695889189577307] -0.25+/-0.12 1.037+/-0.017
[[ 6.63261461e-07 2.78217566e-08 -6.06927636e-08 3.19311018e-07 2.35363698e-06 3.30856395e-08 -4.31785101e-09] [ 2.78217566e-08 6.62224142e-07 5.36091943e-07 -1.06024543e-09 -3.73384344e-06 -4.62719946e-08 -3.58686579e-09] [-6.06927636e-08 5.36091943e-07 2.97469034e-05 -9.81264495e-07 -2.19552836e-04 -2.72946364e-06 1.07267352e-07] [ 3.19311018e-07 -1.06024543e-09 -9.81264495e-07 8.57293002e-06 6.08988587e-05 8.65049757e-07 -4.09387130e-08] [ 2.35363698e-06 -3.73384344e-06 -2.19552836e-04 6.08988587e-05 2.50178699e-03 3.19521667e-05 -1.01035739e-06] [ 3.30856395e-08 -4.62719946e-08 -2.72946364e-06 8.65049757e-07 3.19521667e-05 4.09562854e-07 -1.29983583e-08] [-4.31785101e-09 -3.58686579e-09 1.07267352e-07 -4.09387130e-08 -1.01035739e-06 -1.29983583e-08 3.24431537e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0024.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.46933173 -0.52365608 68.44862104 79.69376902 8.55889508 0.14490193 0.19973992] [0.4693317279043957+/-0.0012398708835889617, -0.52365608214697+/-0.001243833717484958, 68.44862104256372+/-0.004740641966225816, 79.69376902106166+/-0.004200576373106879, 8.558895084616607+/-0.038550965523482986, 0.14490193286530342+/-0.00051255849144265, 0.19973991576741862+/-0.0008741635432718146] -5.46+/-0.11 1.886+/-0.008
[[ 1.53727981e-06 -1.26883061e-07 -5.24643276e-08 -3.04326913e-07 -1.06273067e-06 -1.59289384e-08 -6.96059054e-09] [-1.26883061e-07 1.54712232e-06 -2.47690085e-07 2.78648443e-09 1.21778583e-06 1.53616332e-08 4.61758120e-09] [-5.24643276e-08 -2.47690085e-07 2.24736863e-05 4.89463591e-06 -1.09679870e-04 -1.32123910e-06 5.00083820e-08] [-3.04326913e-07 2.78648443e-09 4.89463591e-06 1.76448419e-05 6.13560282e-05 9.60252721e-07 -5.06458329e-10] [-1.06273067e-06 1.21778583e-06 -1.09679870e-04 6.13560282e-05 1.48617694e-03 1.96757858e-05 -3.03037192e-07] [-1.59289384e-08 1.53616332e-08 -1.32123910e-06 9.60252721e-07 1.96757858e-05 2.62716207e-07 -4.23653995e-09] [-6.96059054e-09 4.61758120e-09 5.00083820e-08 -5.06458329e-10 -3.03037192e-07 -4.23653995e-09 7.64161900e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0025.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ -0.39410694 0.12459941 67.93791091 74.97416113 -16.5680641 -0.21743073 0.20948915] [-0.39410693746182196+/-0.007824278228663505, 0.12459940887695808+/-0.00780903507914806, 67.93791091402011+/-0.035371535618831745, 74.97416112854074+/-0.1126353665866334, -16.568064096415604+/-1.71041148043137, -0.21743072581946746+/-0.024778588270115993, 0.20948915200384255+/-0.00546770790428157] -1.31+/-0.25 1.122+/-0.024
[[ 6.12193298e-05 3.45194356e-06 -6.02668080e-06 9.22619319e-05 8.74550871e-04 1.27322434e-05 -8.88696128e-07] [ 3.45194356e-06 6.09810289e-05 2.81474422e-05 -1.18904822e-05 -4.59838497e-04 -6.43265040e-06 1.52247200e-07] [-6.02668080e-06 2.81474422e-05 1.25114553e-03 -1.04721306e-03 -3.14800486e-02 -4.40580590e-04 -1.29116659e-06] [ 9.22619319e-05 -1.18904822e-05 -1.04721306e-03 1.26867258e-02 1.68472350e-01 2.45693825e-03 -1.39829693e-05] [ 8.74550871e-04 -4.59838497e-04 -3.14800486e-02 1.68472350e-01 2.92550743e+00 4.23699671e-02 -1.65037363e-04] [ 1.27322434e-05 -6.43265040e-06 -4.40580590e-04 2.45693825e-03 4.23699671e-02 6.13978437e-04 -2.44335584e-06] [-8.88696128e-07 1.52247200e-07 -1.29116659e-06 -1.39829693e-05 -1.65037363e-04 -2.44335584e-06 2.98958297e-05]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0026.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 4.44366900e-01 2.66574444e-01 6.72990302e+01 7.87716736e+01 -2.20118639e+00 -1.80742105e-02 2.87548435e-01] [0.44436689952497294+/-0.0008057078613406243, 0.2665744441967905+/-0.000806350409201086, 67.29903017115484+/-0.0031922629719727097, 78.77167363186005+/-0.005310908122071544, -2.201186392861445+/-0.042822473525019035, -0.018074210548751513+/-0.0006086444578400365, 0.2875484345608826+/-0.0005684889345997263] 4.446+/-0.014 0.6062+/-0.0013
[[ 6.49165158e-07 2.76865912e-08 1.90788725e-08 -2.12892634e-07 -2.25871335e-06 -3.32618161e-08 -8.42624202e-09] [ 2.76865912e-08 6.50200982e-07 1.31539465e-07 -1.00627459e-08 -1.60228561e-06 -2.04637770e-08 -2.33101135e-09] [ 1.90788725e-08 1.31539465e-07 1.01905429e-05 2.56392148e-06 -5.93682959e-05 -7.28276106e-07 -2.24799872e-08] [-2.12892634e-07 -1.00627459e-08 2.56392148e-06 2.82057451e-05 1.54522939e-04 2.32585347e-06 -7.79021729e-08] [-2.25871335e-06 -1.60228561e-06 -5.93682959e-05 1.54522939e-04 1.83376424e-03 2.59865839e-05 -2.36466105e-07] [-3.32618161e-08 -2.04637770e-08 -7.28276106e-07 2.32585347e-06 2.59865839e-05 3.70448076e-07 -3.93138310e-09] [-8.42624202e-09 -2.33101135e-09 -2.24799872e-08 -7.79021729e-08 -2.36466105e-07 -3.93138310e-09 3.23179669e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0027.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 0.31899772 -0.46669486 66.52261256 77.77558246 15.48774591 0.20721039 0.25742986] [0.3189977208820208+/-0.0008556571778253599, -0.46669485563898133+/-0.0008529404934444136, 66.52261255724142+/-0.004730865187702112, 77.77558245814802+/-0.0032682643984406176, 15.487745909537642+/-0.03441777415709913, 0.20721039157153676+/-0.00046045215286453784, 0.25742986022623204+/-0.0006020857055192249] 0.515+/-0.013 0.9528+/-0.0012
[[ 7.32149206e-07 -5.41393218e-08 -8.71760686e-09 -1.06457340e-07 -9.53985027e-07 -1.42082918e-08 3.08159378e-09] [-5.41393218e-08 7.27507485e-07 -2.20504649e-07 -2.46567760e-08 1.76545588e-06 2.25097893e-08 4.17438339e-10] [-8.71760686e-09 -2.20504649e-07 2.23810854e-05 3.34011291e-06 -1.08054331e-04 -1.35712637e-06 5.75818984e-08] [-1.06457340e-07 -2.46567760e-08 3.34011291e-06 1.06815522e-05 3.26195013e-05 5.28024165e-07 1.56355210e-08] [-9.53985027e-07 1.76545588e-06 -1.08054331e-04 3.26195013e-05 1.18458318e-03 1.57955910e-05 -8.16882428e-08] [-1.42082918e-08 2.25097893e-08 -1.35712637e-06 5.28024165e-07 1.57955910e-05 2.12016185e-07 -7.31540865e-10] [ 3.08159378e-09 4.17438339e-10 5.75818984e-08 1.56355210e-08 -8.16882428e-08 -7.31540865e-10 3.62507197e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0028.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
[ 2.46613600e-01 -5.06735703e-01 6.56730207e+01 7.73444459e+01 -1.97438189e+00 -4.52850791e-02 2.67762703e-01] [0.24661359998718604+/-0.0008291447543978086, -0.5067357033722734+/-0.0008305268316548282, 65.67302070738201+/-0.00587085117891746, 77.34444594626699+/-0.0028446783665752335, -1.974381890718884+/-0.051448554247940974, -0.04528507912333412+/-0.000686261705995396, 0.2677627026394552+/-0.0005822907035479451] -0.636+/-0.013 1.0569+/-0.0012
[[ 6.87481024e-07 4.47535026e-08 -4.74994536e-08 2.27615563e-07 1.63596696e-06 2.45344447e-08 3.54985964e-09] [ 4.47535026e-08 6.89774818e-07 4.65991730e-07 -3.08619004e-08 -3.93829783e-06 -5.13291229e-08 6.72253352e-09] [-4.74994536e-08 4.65991730e-07 3.44668936e-05 -2.48378295e-06 -2.49168003e-04 -3.25037963e-06 -9.77246385e-08] [ 2.27615563e-07 -3.08619004e-08 -2.48378295e-06 8.09219501e-06 6.22301832e-05 9.13839754e-07 2.67239674e-08] [ 1.63596696e-06 -3.93829783e-06 -2.49168003e-04 6.22301832e-05 2.64695373e-03 3.52502244e-05 7.24411848e-07] [ 2.45344447e-08 -5.13291229e-08 -3.25037963e-06 9.13839754e-07 3.52502244e-05 4.70955129e-07 9.64704815e-09] [ 3.54985964e-09 6.72253352e-09 -9.77246385e-08 2.67239674e-08 7.24411848e-07 9.64704815e-09 3.39062463e-07]]
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0029.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) Cell In[87], line 11 8 guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359) 9 # print(t1, y1) ---> 11 popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess) 12 popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess) 13 print(popt1) File /usr/lib/python3/dist-packages/scipy/optimize/_minpack_py.py:794, in curve_fit(f, xdata, ydata, p0, sigma, absolute_sigma, check_finite, bounds, method, jac, **kwargs) 792 cost = np.sum(infodict['fvec'] ** 2) 793 if ier not in [1, 2, 3, 4]: --> 794 raise RuntimeError("Optimal parameters not found: " + errmsg) 795 else: 796 # Rename maxfev (leastsq) to max_nfev (least_squares), if specified. 797 if 'max_nfev' not in kwargs: RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 1600.
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0030.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0031.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0032.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0033.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0034.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0035.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0036.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0037.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0038.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0039.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0040.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0041.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0042.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0043.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0044.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0045.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0046.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0047.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0048.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0049.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
file1 = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/DLL0050.CSV'
data = np.loadtxt(file1, delimiter=',')
t1 = data[:, 0] # first wave
y1 = data[:, 1] # first wave
t2 = data[:, 2] # second wave
y2 = data[:, 3] # second wave
sigma = np.ones(len(t1))*0.0004
guess = (0.417384, -0.282505, 66.8972, 77.3538, -3.59342, -0.0555561,0.381359)
# print(t1, y1)
popt1, pcov1 = curve_fit(oscillator, t1, y1, sigma=sigma, p0=guess)
popt2, pcov2 = curve_fit(oscillator, t2, y2, sigma=sigma, p0=guess)
print(popt1)
perr1 = np.sqrt(np.diag(pcov1))
perr2 = np.sqrt(np.diag(pcov2))
popt1_u = [ufloat(p, e) for p, e in zip(popt1, perr1)]
popt2_u = [ufloat(p, e) for p, e in zip(popt2, perr2)]
print(popt1_u)
A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1 = popt1
A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2 = popt2
A_1_u, B_1_u, omega_plus_1_u, omega_minus_1_u, phi_1_u, d_1_u, C_1_u = popt1_u
A_2_u, B_2_u, omega_plus_2_u, omega_minus_2_u, phi_2_u, d_2_u, C_2_u = popt2_u
fit_params1.append(popt1_u)
fit_params2.append(popt2_u)
# A_1 = abs(A_1)
# B_1 = abs(B_1)
# A_2 = abs(A_2)
# B_2 = abs(B_2)
DELTA_1_u = (omega_plus_1_u - omega_minus_1_u) * (abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)) # Detuning
OMEGA_1_u = (omega_plus_1_u - omega_minus_1_u) * (1 - ((abs(B_1_u) - abs(A_1_u)) / (abs(B_1_u) + abs(A_1_u)))**2)**0.5 # Rabi Frequency
omega_g_u = (omega_plus_1_u + omega_minus_1_u - DELTA_1_u) / 2 # Ground State Frequency
DELTA_2_u = (omega_plus_2_u - omega_minus_2_u) * (abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)) # Detuning
OMEGA_2_u = (omega_plus_2_u - omega_minus_2_u) * (1 - ((abs(B_2_u) - abs(A_2_u)) / (abs(B_2_u) + abs(A_2_u)))**2)**0.5 # Rabi Frequency
omega_e_u = (omega_plus_2_u + omega_minus_2_u - DELTA_2_u) / 2 # Excited State Frequency
DELTA_u = (DELTA_1_u + DELTA_2_u) / 2 # Average Detuning
OMEGA_u = (OMEGA_1_u + OMEGA_2_u) / 2 # Average Rabi Frequency
GEOMETRIC_PHASE_u = np.pi * (1 - (DELTA_u / (unumpy.sqrt(OMEGA_u**2 + DELTA_u**2)))) # Geometric Phase
print(DELTA_u, GEOMETRIC_PHASE_u/np.pi)
curve_t1 = np.linspace(0, 2, 1000)
curve_y1 = oscillator(curve_t1, A_1, B_1, omega_plus_1, omega_minus_1, phi_1, d_1, C_1)
curve_t2 = np.linspace(0, 2, 1000)
curve_y2 = oscillator(curve_t2, A_2, B_2, omega_plus_2, omega_minus_2, phi_2, d_2, C_2)
# print(curve_y2)
fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(12, 8), sharex=True, sharey=True)
ax1.plot(t1, y1, '*', label='Recorded data')
ax1.plot(curve_t1, curve_y1, 'black', label='Fitted curve')
# ax1.set_xlabel('time (s)')
ax1.set_ylabel('Normalised displacement of first oscillator')
ax1.legend()
ax2.plot(t2, y2, '*', label='Recorded data')
ax2.plot(curve_t2, curve_y2, 'black', label='Fitted curve')
ax2.set_xlabel('time (s)')
ax2.set_ylabel('Normalised displacement of second oscillator')
ax2.legend()
fig.align_ylabels()
plt.tight_layout()
# fig.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=2)
plt.savefig(f"{file1[-6:-4]}.png",dpi=600)
plt.show()
print(pcov1)
filename = '/home/ws10/maitrey/p442-integrated-lab/IV. Coupled Oscillator/DKMM/ALL0050.CSV'
data = np.genfromtxt(filename, skip_header=300, delimiter=',')
t1 = data[:, 0] # first wave
t1 = t1 - t1[0]
y1 = data[:, 1] # first wave
y1 = y1 / np.max(y1)
t2 = data[:, 2] # second wave
t2 = t2 - t2[0]
y2 = data[:, 3] # second wave
y2 = y2 / np.max(y2)
print(t1)
[0.0000e+00 4.0000e-04 8.0000e-04 ... 1.8860e+00 1.8864e+00 1.8868e+00]